//
//  WLStatusModel.swift
//  WLWeibo
//
//  Created by Devil on 16/8/13.
//  Copyright © 2016年 Wiliam. All rights reserved.
//

import UIKit

class WLStatusModel: NSObject {

    var created_at: String?
    
    var id: Int64 = 0
    
    var text: String?
    
    var source: String?
    
    var user: WLUserModel?
    
    var retweeted_status:WLStatusModel?
    
    var pic_urls: [WLPictureInfo]?
    
    var reposts_count: Int = 0
    
    var comments_count: Int = 0
    
    var attitudes_count: Int = 0
    
    
    
    init(dict:[String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
        
            guard let v = value as? [String:AnyObject] else{
            
                return
            }
            user = WLUserModel(dict: v)
        }else if key == "retweeted_status"{
            
            guard let v = value as? [String:AnyObject] else{
            
                return
            }
            retweeted_status = WLStatusModel(dict: v)
            
        }else if key == "pic_urls"{
            
            guard let v = value as? [[String:AnyObject]] else{
            
                return
            }
            var tempArray:[WLPictureInfo] = [WLPictureInfo]()
            
            for dic in v {
                let pic = WLPictureInfo(dict:dic)
                
                tempArray.append(pic)
                
            }
            
            pic_urls = tempArray
            
            
        }else{
        
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
}
